package com.zj.classwork;
import java.util.Scanner;
public class ClassWork16 {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        System.out.println("请输入一个四位整数：");
        int number= input.nextInt();
        int arr[]=new int[4];
        arr[0]=number%10;
        arr[1]=number/10%10;
        arr[2]=number/100%10;
        arr[3]=number/1000;
        int sum=0;
        for(int i=0;i<4;i++)
        {
            if (arr[i]%2==0)
            {
                switch (i)
                {
                    case 0:
                        System.out.println("个位为偶数");
                        break;
                    case 1:
                        System.out.println("十位为偶数");
                        break;
                    case 2:
                        System.out.println("百位为偶数");
                        break;

                    case 3:
                        System.out.println("千位为偶数");
                        break;
                }
            }
            else {
                switch (i)
                {
                    case 0:
                        System.out.println("个位为奇数");
                        break;
                    case 1:
                        System.out.println("十位为奇数");
                        break;
                    case 2:
                        System.out.println("百位为奇数");
                        break;
                    case 3:
                        System.out.println("千位为奇数");
                        break;
                }
            }
            sum+=arr[i];
        }
        System.out.println("各位之和为"+sum);

    }
}
